{extend name="layout/popup" /}
{block name="content"}
<input type="hidden" name="ajax" id="ajax" value="1">
<div class="td-content-wrap p20">
    <div class="td-content-header">
        <h1 class="main-title">编辑轮播图</h1>
    </div>
    <hr>
    <div class="space-20"></div>
    <form id="form_data" class="layui-form" method="post" action="{:url('save')}">
        <input type="hidden" name="opmode" value="edit">
        <input type="hidden" name="id" value="{$vo.id}">
        <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label required">轮播图名称：</label>
                <div class="layui-input-block w280">
                    <input type="text" name="title" placeholder="请输入轮播图名称" class="layui-input" check="required" info="请输入轮播图名称" value="{$vo.title}" />
                </div>
            </div>
        </div>

        <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label ">排序值：</label>
                <div class="layui-input-block w280">
                    <input type="number" name="sort" placeholder="请输入排序值。数字越大，越靠前" class="layui-input" value="{$vo.sort}" />
                </div>
            </div>
        </div>

        <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label required">轮播图 ：</label>
                <div class="layui-input-block">
                    <div class="image-upload">
                        <div class="input">
                            <input type="hidden" class="image-url" name="img" check="required" info="请上传轮播图" value="{$vo.img}" />
                        </div>
                        <div class="image-upload-btn">
                            <p>上传轮播图: 720*360</p>
                        </div>
                        <div class="image"></div>
                    </div>
                </div>
            </div>
        </div>
        <hr>
    </form>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <a class="layui-btn" onclick="save();">保存</a>
            <a class="layui-btn layui-btn-primary" onclick="go_return_url();">取消</a>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    layui.use(['form', 'ueditor', 'uploader'], function () {
        let $ = layui.jquery;
        var form = layui.form;
        let fn = {
            select_category: function () {
                popup_open("{:url('select_category')}", 560, 470);
            },
            save: function () {
                send_form("form_data", "{:url('save')}", function (res) {
                    if (res.code) {
                        layer.msg(res.msg, {
                            time: 1200
                        }, function () {
                            location.href = '{:url("index")}';
                        });
                    } else {
                        layer.msg(res.msg);
                        return false;
                    }
                });
            }
        };
        win_exp(fn);

    });
</script>
{/block}
